home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Games / NeXTGo / Source / fioe.c < prev    next >
C/C++ Source or Header  |  1993-02-08  |  2KB  |  51 lines

  1. #include "comment.header"
  2.  
  3. extern unsigned char p[19][19];
  4. extern int MAXX, MAXY;
  5. extern int currentStone;
  6.  
  7. int fioe(int i, int j)
  8. {
  9.   /* check top edge */
  10.   if (i == 0)
  11.     {
  12.       if ((j == 0) && ((p[1][0] == currentStone) && (p[0][1] == currentStone))) return 1;
  13.       if ((j == MAXY - 1) && ((p[1][MAXY - 1] == currentStone) && (p[0][MAXY - 2] == currentStone))) return 1;
  14.       if ((p[1][j] == currentStone) &&
  15.       ((p[0][j - 1] == currentStone) && (p[0][j + 1] == currentStone))) return 1;
  16.       else
  17.     return 0;
  18.     }
  19.   /* check bottom edge */
  20.   if (i == MAXX - 1)
  21.     {
  22.       if ((j == 0) && ((p[MAXX - 2][0] == currentStone) && (p[MAXX - 1][1] == currentStone))) return 1;
  23.       if ((j == MAXY - 1) && ((p[MAXX - 2][MAXY - 1] == currentStone) && (p[MAXX - 1][MAXY - 2] == currentStone))) return 1;
  24.       if ((p[MAXX - 2][j] == currentStone) &&
  25.       ((p[MAXX - 1][j - 1] == currentStone) && (p[MAXX - 1][j + 1] == currentStone)))
  26.     return 1;
  27.       else
  28.     return 0;
  29.     }
  30.   /* check left edge */
  31.   if (j == 0)
  32.     if ((p[i][1] == currentStone) &&
  33.     ((p[i - 1] [0] == currentStone) && (p[i + 1][0] == currentStone)))
  34.       return 1;
  35.     else
  36.       return 0;
  37.   /* check right edge */
  38.   if (j == MAXY - 1)
  39.     if ((p[i][MAXY - 2] == currentStone) &&
  40.     ((p[i - 1][MAXY - 1] == currentStone) && (p[i + 1][MAXY - 1] == currentStone)))
  41.       return 1;
  42.     else
  43.       return 0;
  44.   /* check center pieces */
  45.   if (((p[i][j - 1] == currentStone) && (p[i][j + 1] == currentStone)) &&
  46.       ((p[i - 1][j] == currentStone) && (p[i + 1][j] == currentStone)))
  47.     return 1;
  48.   else
  49.     return 0;
  50. }  /* fioe */
  51.